package cn.edu.zju.gis.disasterBE.sever.mapper;

import cn.edu.zju.gis.disasterBE.sever.entity.imageQuery;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface imageMapper {
    @Insert({"insert into image_info ( mid,title,platformname,producttype,date,resolution,cloudcoverpercentage,footprint,instrumentname,orbitnumber,did,filename,downloadstate) values( #{id},#{title},#{platformname},#{producttype},#{date}::timestamp,#{resolution},#{cloudcoverpercentage},ST_MPolyFromText(#{footprint},4326),#{instrumentname},#{orbitnumber},#{did},#{filename},'downloaded') ON CONFLICT (mid) DO NOTHING"})
    Integer addImage(imageQuery iQ);

    @Update({"UPDATE image_info SET downloadstate = 'downloaded' where mid = #{id}"})
    Integer downloaded(String id);

    @Select("select mid,title,platformname,producttype,date,resolution,cloudcoverpercentage,footprint,instrumentname,orbitnumber,0,did,filename from image_info")
    List<imageQuery> selectAll();

    @Select("select title from image_info where mid = #{id}")
    String selectFileName(String id);
}
